<?php

require_once dirname(__FILE__) . '/../lib/pending_teacherGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/pending_teacherGeneratorHelper.class.php';

/**
 * pending_teacher actions.
 *
 * @package    sf_sandbox
 * @subpackage pending_teacher
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class pending_teacherActions extends autoPending_teacherActions {

    public function executeApprove(sfWebRequest $request) {
        $id = $request->getParameter('intg_identity');
        $object = PendingTeacherTable::getInstance()->find($id);
        $old_object = TeacherTable::getInstance()->find($id);
        $data = $object->getData();

        if (is_object($old_object)) {
            $old_object->set('school_intg_id', $data['school_intg_id']);
            $old_object->save();
        } else {
            $teacher = new Teacher();
            foreach ($data as $k => $one) {
                $teacher->set($k, $one);
            }
            $teacher->save();
        }

        $object->delete();
        $this->getUser()->setFlash('notice', I18nUtilities::__('Saved successfully'));
        $this->redirect($request->getReferer());
    }

}
